//
// MethodReturnTypeTests.m
// Copyright 2010 Mark Buer
//
// This file is part of zc-aspect.
//
// zc-aspect is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// zc-aspect is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with zc-aspect.  If not, see <http://www.gnu.org/licenses/>.
//

#import "MethodReturnTypeTests.h"
#import "ZCAspect.h"
#import "MethodsWithDifferentReturnTypes.h"


@interface MethodReturnTypeTests ()

@property (assign, nonatomic) BOOL didIntercept;
@property (retain, nonatomic) MethodsWithDifferentReturnTypes *testSubject;

@end



@implementation MethodReturnTypeTests

@synthesize didIntercept;
@synthesize testSubject;


#pragma mark -
#pragma mark Test Initialisation


- (void)setUp {
	self.testSubject = [[[MethodsWithDifferentReturnTypes alloc] init] autorelease];

	[ZCInterceptionManager watchClass:[MethodsWithDifferentReturnTypes class] withInterceptor:self excludingSelectors:nil];
	didIntercept = NO;
}


- (void)tearDown {
	self.testSubject = nil;
}


#pragma mark -
#pragma mark Interceptor(Delegate) TODO Fix my name!


- (void)interceptInvocation:(Invocation *)invocation {
	didIntercept = YES;
	invocation_invoke(invocation);
}


#pragma mark -
#pragma mark Test Methods


- (void)testReturnsChar {
	STAssertTrue([testSubject returnsChar] == CHAR_RETURN_VALUE, nil);
    STAssertTrue(didIntercept, nil);
}


- (void)testReturnsInt {
	STAssertTrue([testSubject returnsInt] == INT_RETURN_VALUE, nil);
    STAssertTrue(didIntercept, nil);
}


- (void)testReturnsShort {
	STAssertTrue([testSubject returnsShort] == SHORT_RETURN_VALUE, nil);
    STAssertTrue(didIntercept, nil);
}


- (void)testReturnsLong {
	STAssertTrue([testSubject returnsLong] == LONG_RETURN_VALUE, nil);
    STAssertTrue(didIntercept, nil);
}


- (void)testReturnsLongLong {
	STAssertTrue([testSubject returnsLongLong] == LONG_LONG_RETURN_VALUE, nil);
    STAssertTrue(didIntercept, nil);
}


- (void)testReturnsUnsignedChar {
	STAssertTrue([testSubject returnsUnsignedChar] == U_CHAR_RETURN_VALUE, nil);
    STAssertTrue(didIntercept, nil);
}


- (void)testReturnsUnsignedInt {
	STAssertTrue([testSubject returnsUnsignedInt] == U_INT_RETURN_VALUE, nil);
    STAssertTrue(didIntercept, nil);
}


- (void)testReturnsUnsignedShort {
	STAssertTrue([testSubject returnsUnsignedShort] == U_SHORT_RETURN_VALUE, nil);
    STAssertTrue(didIntercept, nil);
}


- (void)testReturnsUnsignedLong {
	STAssertTrue([testSubject returnsUnsignedLong] == U_LONG_RETURN_VALUE, nil);
    STAssertTrue(didIntercept, nil);
}


- (void)testReturnsUnsignedLongLong {
	STAssertTrue([testSubject returnsUnsignedLongLong] == U_LONG_LONG_RETURN_VALUE, nil);
    STAssertTrue(didIntercept, nil);
}


- (void)testReturnsFloat {
	STAssertTrue([testSubject returnsFloat] == FLOAT_RETURN_VALUE, nil);
    STAssertTrue(didIntercept, nil);
}


- (void)testReturnsDouble {
	STAssertTrue([testSubject returnsDouble] == DOUBLE_RETURN_VALUE, nil);
    STAssertTrue(didIntercept, nil);
}


- (void)testReturnsLongDouble {
	STAssertTrue([testSubject returnsLongDouble] == LONG_DOUBLE_RETURN_VALUE, nil);
    STAssertTrue(didIntercept, nil);
}


- (void)testReturnsC99Bool {
	STAssertTrue([testSubject returnsC99Bool] == C99BOOL_RETURN_VALUE, nil);
    STAssertTrue(didIntercept, nil);
}


- (void)testReturnsVoidPointer {
	STAssertTrue([testSubject returnsVoidPointer] == VOIDPOINTER_RETURN_VALUE, nil);
    STAssertTrue(didIntercept, nil);
}


@end
